<template>
    <!-- 审批处理看板 -->
   <div class="approval">
  <el-row :gutter="20">
    <el-col :xs="24" :sm="12" :md="8">
      <el-statistic
        title="✅待我审批"
        :value="statusStats.pending"
        suffix="个"
      />
    </el-col>
    <el-col :xs="24" :sm="12" :md="8">
      <el-statistic
        title="📄 已通过"
        :value="statusStats.approved"
        suffix="个"
      />
    </el-col>
    <el-col :xs="24" :sm="24" :md="8">
      <el-statistic 
        title="❌ 已拒绝" 
        :value="statusStats.rejected"
        suffix="个"
      />
    </el-col>
  </el-row>
</div>
  <div class="contract-approval">
    <!-- 标题和分割线 -->
    <div class="header-section">
      <h1 class="contract-title">合同审批</h1>
      <div class="divider"></div>
    </div>
    
    

    <!-- 搜索和筛选区域 -->
    <el-form inline style="display: flex; justify-content: space-between; align-items: center; width: 100%;">
      <div style="display: flex; flex-wrap: wrap; gap: 10px;">
        <el-form-item label="审批状态">
          <el-select v-model="params.status" style="width:100px">
            <el-option label="全部" value="全部"></el-option>
            <el-option label="待审批" value="待审批"></el-option>
            <el-option label="已通过" value="已通过"></el-option>
            <el-option label="已拒绝" value="已拒绝"></el-option>
          </el-select>
        </el-form-item>
        
        <el-form-item label="合同名称">
          <el-input v-model="params.contractName" placeholder="输入合同名称" clearable style="width:150px"></el-input>
        </el-form-item>
        
        <el-form-item label="申请日期">
          <el-date-picker
            v-model="params.createdAt"
            type="date"
            placeholder="选择日期"
            value-format="YYYY-MM-DD"
            style="width:120px"
          />
        </el-form-item>
        
        <el-form-item>
          <el-button @click="onSearch" type="primary">查询</el-button>
          <el-button @click="onReset">重置</el-button>
        </el-form-item>
      </div>

      <el-form-item>
        <el-button 
        type="primary" 
        @click="onBatchApprove" 
        style="width: 94px" 
        :disabled="selectedContracts.length === 0"
        >
          批量通过
        </el-button>
        <el-button type="primary" @click="onBatchExport" style="width: 94px;">
          批量导出
        </el-button>
      </el-form-item> 
    </el-form>
    
    <!-- 合同审批表格 -->
    <el-table 
    :data="tableData" 
    v-loading="loading" 
    style="width: 100%"
    border
    :scroll-x="true" 
    @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" />
      <el-table-column type="index" label="序号" width="80"></el-table-column>
      <el-table-column label="合同编号" prop="contractNumber" width="180"></el-table-column>
      <el-table-column label="合同名称" prop="title" width="200"></el-table-column>
      <el-table-column label="申请人" prop="applicant" width="150"></el-table-column>
      <el-table-column label="申请日期" width="200">
       <template #default="{ row }">
         {{ formatDateTime(row.createdAt) }}
       </template>
      </el-table-column>
      <el-table-column label="状态" prop="contractStatus" width="120">
        <template #default="{ row }">
          <el-tag :type="getStatusTagType(row.contractStatus)">
            {{ row.contractStatus }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column 
        label="操作" 
        width="220"
        fixed="right"
        >
        <template #default="{ row }">
          <el-button size="small" @click="onViewContractDetail(row)">查看</el-button>
          <el-button 
          size="small" 
          v-if="row.contractStatus ==='待审批' " 
          type="success" 
          @click="onApproveContract(row)"
          >
            通过
          </el-button>
          <el-button size="small" v-if="row.contractStatus === '待审批'" type="danger" @click="onRejectContract(row)">
            拒绝
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <!-- 分页区域 -->
    <el-pagination
      v-model:current-page="params.pagenum"
      v-model:page-size="params.pagesize"
      :page-sizes="[2, 3, 5, 10]"
      :background="true"
      layout="jumper,total, sizes, prev, pager, next"
      :total="total"
      @size-change="onSizeChange"
      @current-change="onCurrentChange"
      style="margin-top:20px;justify-content: flex-end;"
    />
    
    <!-- 合同详情弹窗 -->
    <el-dialog v-model="showContractDetail" :title="`合同详情 - ${currentContract?.contractNumber || ''}`" width="60%">
      <div v-if="currentContract" class="contract-detail-content">
        <div class="info-section">
          <div class="info-grid">
            <div class="info-item">
              <span class="info-label">合同编号：</span>
              <span class="info-value">{{ currentContract.contractNumber }}</span>
            </div>
            <div class="info-item">
              <span class="info-label">合同名称：</span>
              <span class="info-value">{{ currentContract.title || currentContract.name }}</span>
            </div>
            <div class="info-item">
              <span class="info-label">申请人：</span>
              <span class="info-value">{{ currentContract.applicant }}</span>
            </div>
            <div class="info-item">
              <span class="info-label">申请日期：</span>
              <span class="info-value">{{ formatDateTime(currentContract.createdAt) || '无' }}</span>
            </div>

          </div>
        </div>
        
        <div class="info-section">
          <h3>合同基本信息</h3>
          <div class="info-grid">
            <div class="info-item">
              <span class="info-label">合同类型：</span>
              <span class="info-value">{{ currentContract.contractType }}</span>
            </div>
            <div class="info-item">
              <span class="info-label">开始日期：</span>
              <span class="info-value">{{ currentContract.startDate }}</span>
            </div>
            <div class="info-item">
              <span class="info-label">结束日期：</span>
              <span class="info-value">{{ currentContract.endDate }}</span>
            </div>

          </div>
        </div>
        
        
        <div class="info-section">
          <h3>审批信息</h3>
          <div class="info-grid">
            <div class="info-item">
              <span class="info-label">审批状态：</span>
              <span class="info-value">
                <el-tag :type="getStatusTagType(currentContract.approvalStatus)">
                  {{ currentContract.approvalStatus }}
                </el-tag>
              </span>
            </div>
            <div class="info-item" v-if="currentContract.status !== '待审批'">
              <span class="info-label">审批人：</span>
              <span class="info-value">{{ currentContract.approver }}</span>
            </div>
            <div class="info-item" v-if="currentContract.status !== '待审批'">
              <span class="info-label">审批时间：</span>
              <span class="info-value">{{ currentContract.approvalTime }}</span>
            </div>
            <div class="info-item" v-if="currentContract.status === '已拒绝'">
              <span class="info-label">拒绝原因：</span>
              <span class="info-value">{{ currentContract.rejectReason }}</span>
            </div>
          </div>
        </div>
      </div>
      
      <template #footer>
        <el-button @click="showContractDetail = false">关闭</el-button>
        <el-button type="primary" @click="onExportContract(currentContract)">导出合同</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import * as XLSX from 'xlsx'
import { ref, computed, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useContractStore } from '@/stores/contractStore'

const contractStore = useContractStore()

// 审批统计数据
const statusStats = ref({
  pending: 0,
  approved: 0,
  rejected: 0,
  total: 0
})

// 筛选后的完整合同列表
const filteredList = ref([])

// 计算当前页显示的数据
const paginatedList = computed(() => {
  const start = (params.value.pagenum - 1) * params.value.pagesize
  const end = start + params.value.pagesize
  return filteredList.value.slice(start, end)
})

// 表格数据使用分页后的数据
const tableData = computed(() => {
  return paginatedList.value
})

const loading = ref(false)
const total = computed(() => filteredList.value.length)

// 请求参数
const params = ref({
  pagenum: 1,
  pagesize: 5,
  status: '',
  contractName: '',
  applyDate: ''
})

// 当前查看的合同
const currentContract = ref(null)
const showContractDetail = ref(false)

// 获取状态标签类型
const getStatusTagType = (status) => {
  switch (status) {
    case '已通过': return 'success'
    case '待审批': return 'warning'
    case '已拒绝': return 'danger'
    default: return ''
  }
}

// 加载审批统计数据
const loadApprovalStats = async () => {
  try {
    const response = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/approval-records/stats`)
    if (response.ok) {
      const result = await response.json()
      if (result.success) {
        statusStats.value = {
          pending: result.data.pending || 0,
          approved: result.data.approved || 0,
          rejected: result.data.rejected || 0,
          total: result.data.total || 0
        }
        ElMessage(statusStats.value.pending);
      } else {
        console.error('获取审批统计失败:', result.message)
      }
    } else {
      console.error('获取审批统计请求失败')
    }
  } catch (error) {
    console.error('加载审批统计数据失败:', error)
  }
}

// 加载所有合同数据
const loadAllContracts = async () => {
  loading.value = true
  try {
    const response = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/contracts`)
    if (response.ok) {
      const data = await response.json()
      if (data.success) {
        filteredList.value = data.data
        total.value = data.data.length
        
        // 更新审批统计数据
        updateApprovalStats(data.data)
        
        ElMessage.success(`加载 ${data.data.length} 条合同数据成功`)
      } else {
        ElMessage.error('获取合同列表失败: ' + data.message)
      }
    } else {
      ElMessage.error('网络请求失败')
    }
  } catch (error) {
    ElMessage.error('加载合同数据失败: ' + error.message)
  } finally {
    loading.value = false
  }
}
// 日期格式化方法
const formatDateTime = (dateString) => {
  if (!dateString) return '无'
  
  try {
    // 替换T字符并格式化
    return dateString.replace('T', ' ').substring(0, 19)
  } catch (error) {
    return dateString // 如果格式化失败，返回原字符串
  }
}

// 筛选合同
const filterContracts = () => {
  loading.value = true
  
  // 合并两个列表并去重
  const allContracts = [
    ...contractStore.contracts,
    ...contractStore.pendingApprovals
  ].filter((contract, index, self) =>
    index === self.findIndex(c => c.id === contract.id)
  )
  
  // 应用筛选条件
  filteredList.value = allContracts.filter(contract => {
    const statusMatch = !params.value.status || 
                       params.value.status === '全部' || 
                       contract.status === params.value.status
    const nameMatch = !params.value.contractName || 
                     contract.title?.includes(params.value.contractName) ||
                     contract.name?.includes(params.value.contractName)
    const dateMatch = !params.value.applyDate || 
                     contract.applyDate === params.value.applyDate
    return statusMatch && nameMatch && dateMatch
  })
  
  loading.value = false
}

// 更新审批统计数据
const updateApprovalStats = (contracts) => {
  statusStats.value = {
    pending: contracts.filter(c => c.contractStatus === '待审批').length,
    approved: contracts.filter(c => c.contractStatus === '已通过').length,
    rejected: contracts.filter(c => c.contractStatus === '已拒绝').length,
    total: contracts.length
  }
  console.log("待审批数：",statusStats.value.pending)
}

// 条件搜索合同
const searchContracts = async () => {
  loading.value = true
  try {
    // 构建搜索参数
    const searchParams = {
      contractStatus: params.value.status === '全部' ? undefined : params.value.status,
      title: params.value.contractName || undefined,
      startDate: params.value.applyDate || undefined
    }
    
    // 过滤掉undefined的参数
    const filteredParams = Object.fromEntries(
      Object.entries(searchParams).filter(([_, value]) => value !== undefined && value !== '')
    )
    
    console.log('搜索参数:', filteredParams)
    
    const response = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/contracts/search`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(filteredParams)
    })
    
    if (response.ok) {
      const data = await response.json()
      if (data.success) {
        filteredList.value = data.data
        total.value = data.data.length
        
        // 更新审批统计数据
        updateApprovalStats(data.data)
        
        ElMessage.success(`找到 ${data.data.length} 条合同`)
      } else {
        ElMessage.error('搜索失败: ' + data.message)
      }
    } else {
      ElMessage.error('搜索请求失败')
    }
  } catch (error) {
    ElMessage.error('搜索合同失败: ' + error.message)
  } finally {
    loading.value = false
  }
}

// 分页相关方法
const onSizeChange = (size) => {
  params.value.pagenum = 1
  params.value.pagesize = size
  // 不需要重新调用 filterContracts，因为 computed 属性会自动更新
}

const onCurrentChange = (page) => {
  params.value.pagenum = page
  // 不需要重新调用 filterContracts，因为 computed 属性会自动更新
}

// 搜索和重置
const onSearch = () => {
  params.value.pagenum = 1
  searchContracts()
}

const onReset = () => {
  params.value = {
    pagenum: 1,
    pagesize: 5,
    status: '',
    contractName: '',
    applyDate: ''
  }
  loadAllContracts()
}

// 查看合同详情
const onViewContractDetail = async (contract) => {
  try {
    // 先设置基本合同信息
    currentContract.value = {
      ...contract,
      title: contract.title,
      startDate: contract.startDate,
      endDate: contract.endDate,
      applyDate: contract.applyDate,
      rejectReason: contract.rejectReason || '',
      approver: '无',
      approvalTime: '无',
      approvalStatus: contract.contractStatus
    }
    
    // 调用查询最新审核记录API
    const response = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/approval-records/contract/${contract.id}/latest`)
    
    if (response.ok) {
      const result = await response.json()
      if (result.success && result.data) {
        const latestRecord = result.data
        // 更新审批信息
        currentContract.value.approver = latestRecord.approver
        currentContract.value.approvalTime = latestRecord.approvalTime
        currentContract.value.approvalStatus = latestRecord.approvalStatus
        currentContract.value.rejectReason = latestRecord.rejectReason || contract.rejectReason || ''
      } else {
        // 如果没有审核记录，使用合同本身的审批信息
        console.log('未找到审核记录，使用合同信息')
      }
    } else {
      console.error('查询审核记录失败')
    }
  } catch (error) {
    console.error('加载合同详情失败:', error)
  } finally {
    showContractDetail.value = true
  }
}


// 审批通过
const onApproveContract = async (contract) => {
  ElMessageBox.confirm(`确定要通过合同 ${contract.contractNumber} 的审批吗?`, '确认通过', {
    confirmButtonText: '确认通过',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(async () => {
    try {
      // 1. 更新合同状态为已通过 - 按照Mapper格式发送完整合同对象
      const updateData = {
        id: contract.id,
        contractNumber: contract.contractNumber,
        title: contract.title,
        applicant: contract.applicant,
        companyName: contract.companyName,
        companyAddress: contract.companyAddress,
        contractType: contract.contractType,
        startDate: contract.startDate,
        endDate: contract.endDate,
        contractStatus: '已通过' // 只修改状态字段
      }
      
      const updateResponse = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/contracts/${contract.id}`, {
        method: 'PUT',
        headers: {
          'Content-Type': 'application/json'
        },
        body: JSON.stringify(updateData)
      })
      
      if (updateResponse.ok) {
        const updateResult = await updateResponse.json()
        if (updateResult.success) {
          // 2. 调用添加审核记录API
          const approvalRecord = {
            contractId: contract.id,
            approver: '审批人', // 这里可以替换为实际的用户信息
            approvalStatus: '已通过',
            rejectReason: null,
            approvalTime: new Date().toISOString().replace('T', ' ').substring(0, 19)
          }
          
          const approvalResponse = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/approval-records`, {
            method: 'POST',
            headers: {
              'Content-Type': 'application/json'
            },
            body: JSON.stringify(approvalRecord)
          })
          
          if (approvalResponse.ok) {
            const approvalResult = await approvalResponse.json()
            if (approvalResult.success) {
              ElMessage.success('审批通过成功')
 
              showContractDetail.value = false
            } else {
              ElMessage.error('添加审批记录失败: ' + approvalResult.message)
            }
          } else {
            ElMessage.error('添加审批记录请求失败')
          }
        } else {
          ElMessage.error('更新合同状态失败: ' + updateResult.message)
        }
      } else {
        ElMessage.error('更新合同请求失败')
      }
    } catch (error) {
      ElMessage.error('审批操作失败: ' + error.message)
    }
  }).catch(() => {})
}

// 审批拒绝
const onRejectContract = async (contract) => {
  ElMessageBox.prompt('请输入拒绝原因', '拒绝审批', {
    confirmButtonText: '确认拒绝',
    cancelButtonText: '取消',
    inputType:'textarea',
    inputAttributes: {
      rows: 4,
      placeholder: '请输入详细的拒绝原因...'
    },
    inputValidator: (value) => {
      if (!value || value.trim().length < 5) {
        return '拒绝原因不能少于5个字符'
      }
    }
  }).then(async ({ value }) => {
    try {
      // 1. 更新合同状态为已拒绝 - 按照Mapper格式发送完整合同对象
      const updateData = {
        id: contract.id,
        contractNumber: contract.contractNumber,
        title: contract.title,
        applicant: contract.applicant,
        companyName: contract.companyName,
        companyAddress: contract.companyAddress,
        contractType: contract.contractType,
        startDate: contract.startDate,
        endDate: contract.endDate,
        contractStatus: '已拒绝', // 修改状态字段
        rejectReason: value // 添加拒绝原因
      }
      
      const updateResponse = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/contracts/${contract.id}`, {
        method: 'PUT',
        headers: {
          'Content-Type': 'application/json'
        },
        body: JSON.stringify(updateData)
      })
      
      if (updateResponse.ok) {
        const updateResult = await updateResponse.json()
        if (updateResult.success) {
          // 2. 调用添加审核记录API
          const approvalRecord = {
            contractId: contract.id,
            approver: '审批人', 
            approvalStatus: '已拒绝',
            rejectReason: value,
            approvalTime: new Date().toISOString().replace('T', ' ').substring(0, 19)
          }
          
          const approvalResponse = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/approval-records`, {
            method: 'POST',
            headers: {
              'Content-Type': 'application/json'
            },
            body: JSON.stringify(approvalRecord)
          })
          
          if (approvalResponse.ok) {
            const approvalResult = await approvalResult.json()
            if (approvalResult.success) {
              ElMessage.success('已拒绝该合同审批')
              // 重新加载数据
              await loadAllContracts()
              showContractDetail.value = false
            } else {
              ElMessage.error('添加审批记录失败: ' + approvalResult.message)
            }
          } else {
            ElMessage.error('添加审批记录请求失败')
          }
        } else {
          ElMessage.error('更新合同状态失败: ' + updateResult.message)
        }
      } else {
        ElMessage.error('更新合同请求失败')
      }
    } catch (error) {
      ElMessage.error('审批操作失败: ' + error.message)
    }
  }).catch(() => {})
}

// 批量审批通过
const onBatchApprove = async () => {
  if(selectedContracts.value.length === 0) return
  
  // 筛选出待审批的选中合同
  const pendingSelectedContracts = selectedContracts.value.filter(c => c.contractStatus === '待审批')
  if (pendingSelectedContracts.length === 0) {
    ElMessage.warning('选中的合同中没有待审批的合同')
    return
  }
  
  ElMessageBox.confirm(`确定要批量通过 ${pendingSelectedContracts.length} 个待审批合同吗?`, '批量审批', {
    confirmButtonText: '确认通过',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(async () => {
    let successCount = 0
    
    for (const contract of pendingSelectedContracts) {
      try {
        // 1. 更新合同状态为已通过 - 按照Mapper格式发送完整合同对象
        const updateData = {
          id: contract.id,
          contractNumber: contract.contractNumber,
          title: contract.title,
          applicant: contract.applicant,
          companyName: contract.companyName,
          companyAddress: contract.companyAddress,
          contractType: contract.contractType,
          startDate: contract.startDate,
          endDate: contract.endDate,
          contractStatus: '已通过' // 只修改状态字段
        }
        
        const updateResponse = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/contracts/${contract.id}`, {
          method: 'PUT',
          headers: {
            'Content-Type': 'application/json'
          },
          body: JSON.stringify(updateData)
        })
        
        if (updateResponse.ok) {
          const updateResult = await updateResponse.json()
          if (updateResult.success) {
            // 2. 调用添加审核记录API
            const approvalRecord = {
              contractId: contract.id,
              approver: '审批人',
              approvalStatus: '已通过',
              rejectReason: null,
              approvalTime: new Date().toISOString().replace('T', ' ').substring(0, 19)
            }
            
            const approvalResponse = await fetch(`${import.meta.env.VITE_API_BASE_URL}/api/approval-records`, {
              method: 'POST',
              headers: {
                'Content-Type': 'application/json'
              },
              body: JSON.stringify(approvalRecord)
            })
            
            if (approvalResponse.ok) {
              const approvalResult = await approvalResponse.json()
              if (approvalResult.success) {
                successCount++
              }
            }
          }
        }
      } catch (error) {
        console.error(`审批合同 ${contract.contractNumber} 失败:`, error)
      }
    }
    
    ElMessage.success(`已批量通过 ${successCount} 个合同`)
    selectedContracts.value = []
    // 重新加载数据
    await loadAllContracts()
  }).catch(() => {})
}


// 已选中的合同
const selectedContracts = ref([])

// 处理选择变化
const handleSelectionChange = (selection) => {
  selectedContracts.value = selection
}


// 导出单个合同
const onExportContract = (contract) => {
  try {
    // 准备导出数据
    const exportData = [
      ['合同编号', contract.number],
      ['合同名称', contract.name],
      ['申请人', contract.applicant],
      ['合同类型', contract.type],
      ['开始日期', contract.startDate],
      ['结束日期', contract.endDate],
      ['申请日期', contract.applyDate],
      ['审批状态', contract.status],
      ['审批人', contract.approver || ''],
      ['审批日期', contract.approveDate || ''],
      ['拒绝原因', contract.rejectReason || '']
    ]
    
    // 创建工作簿
    const wb = XLSX.utils.book_new()
    const ws = XLSX.utils.aoa_to_sheet(exportData)
    XLSX.utils.book_append_sheet(wb, ws, '合同详情')
    
    // 导出文件
    XLSX.writeFile(wb, `${contract.number}_${contract.name}.xlsx`)
    ElMessage.success('合同导出成功')
  } catch (error) {
    ElMessage.error('导出失败：' + error.message)
  }
}

// 批量导出合同
const onBatchExport = () => {
  if (filteredList.value.length === 0) {
    ElMessage.warning('没有可导出的合同数据')
    return
  }
  
  try {
    // 准备表头
    const headers = [
      '序号',
      '合同编号',
      '合同名称',
      '申请人',
      '合同类型',
      '开始日期',
      '结束日期',
      '申请日期',
      '审批状态',
      '审批人',
      '审批日期',
      '拒绝原因'
    ]
    
    // 准备数据
    const data = filteredList.value.map((contract, index) => [
      index + 1,
      contract.number,
      contract.title || contract.name,
      contract.applicant,
      contract.type,
      contract.date,
      contract.contractEndDate,
      contract.applyDate,
      contract.status,
      contract.approver || '',
      contract.approveDate || '',
      contract.rejectReason || ''
    ])
    
    // 创建工作簿
    const wb = XLSX.utils.book_new()
    const ws = XLSX.utils.aoa_to_sheet([headers, ...data])
    XLSX.utils.book_append_sheet(wb, ws, '合同列表')
    
    // 导出文件
    const dateStr = new Date().toISOString().split('T')[0]
    XLSX.writeFile(wb, `合同审批列表_${dateStr}.xlsx`)
    ElMessage.success(`已成功导出${filteredList.value.length}条合同数据`)
  } catch (error) {
    ElMessage.error('批量导出失败：' + error.message)
  }
}

// 初始化
onMounted(() => {
  loadAllContracts()
})
</script>

<style scoped>
.contract-approval {
  padding: 20px;
  font-family: 'Arial', sans-serif;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
}

.header-section {
  margin-bottom: 30px;
}

.contract-title {
  font-size: 20px;
  color: #333;
  margin-bottom: 10px;
  text-align: left;
}

.divider {
  height: 1px;
  background-color: #e0e0e0;
  width: 100%;
}

.info-section {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.info-section h3 {
  color: #333;
  margin-bottom: 15px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 15px;
}

.info-item {
  margin-bottom: 10px;
}

.info-label {
  font-weight: bold;
  color: #555;
}

.info-value {
  color: #333;
}

.contract-detail-content {
  padding: 10px;
}
.approval {
  margin-bottom: 24px;
  padding: 20px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}
</style>